package com.travelbid.admin.struts.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class AdminLoginForm extends ActionForm{
	private String username;
	private String password;
	public String validtime;
	private String checkran;
	private Integer type;
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public AdminLoginForm() {
		super();
		// TODO Auto-generated constructor stub
	}
	public AdminLoginForm(String username, String password,String validtime) {
		super();
		this.username = username;
		this.password = password;
		this.validtime = validtime; 
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getCheckran() {
		return checkran;
	}
	public void setCheckran(String checkran) {
		this.checkran = checkran;
	}
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		String check = (String) request.getSession().getAttribute("check");
		if ((checkran != null) && (check != null)) {
			if (!checkran.toLowerCase().equals(check.toLowerCase())) {
				errors.add("checkerror", new ActionMessage("(验证码不正确!)", false));
			}
		}
		return errors;
	}
	public String getValidtime() {
		return validtime;
	}
	public void setValidtime(String validtime) {
		this.validtime = validtime;
	};
	
}
